<?php


namespace App\Exception;


use Swoole\Http\Status;
use RuntimeException;

class HttpException extends RuntimeException
{
    public $httpStatusCode = Status::BAD_REQUEST;

    public $code;

    public function __construct($params = [])
    {
        if (!is_array($params) && is_int($params)) {
            $this->code = $params;
            return;
        }
        if (array_key_exists('httpStatusCode', $params)) {
            $this->httpStatusCode = $params['httpStatusCode'];
        }
        if (array_key_exists('code', $params)) {
            $this->code = $params['code'];
        }
        if (array_key_exists('message', $params)) {
            $this->message = $params['message'];
        }

    }
}